package org.chen.wx.utils;

import lombok.extern.slf4j.Slf4j;
import org.chen.api.core.OkHttpClientManager;
import org.chen.api.request.StringRequest;
import org.chen.api.utils.JsonUtil;
import org.chen.wx.dto.Msg;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * Author:Mr.Chen
 * Date:2018/8/4
 */
@Slf4j
@Component
public class WxSendUtils {

    @Value("${wx.send}")
    private String send;

    @Resource()
    private OkHttpClientManager clientManager;

    /**
     * @param token
     */
    public void sendMsg(String token, Msg msg) {
        StringRequest request = new StringRequest(send + "?access_token=" + token);
        request.add("body", msg).post().setContentType("application/json");
        String temp = clientManager.send(request).getRawBody();
        System.out.println(temp);
    }
}
